<template>
  <view class="good-list">
    <uni-list class="iconList">
      <uni-list-item
        v-for="(item, index) in list"
        :key="index"
        :title="item.title"
        clickable
        showArrow
        style="width: 100%"
        @click="navigetTo(item)"
      >
        <view slot="body" class="lz-list-body">
          <view class="lz-list-title lz-ellipsis-1">{{ item.title }}</view>
          <view class="lz-list-item lz-ellipsis-1">{{$t('申请人')}}：{{ item.userName }}</view>
          <view class="lz-list-item lz-ellipsis-1">{{$t('日期')}}：{{ item.createDate }}</view>
          <view class="lz-list-item lz-ellipsis-1">
            {{$t('状态')}}：
            <u-tag :text="item.statusName" mode="dark" type="primary" />
          </view>
        </view>
        <view slot="footer" class="lz-list-footer">
          <u-tag
            v-if="option.name === '审批处理'"
            :text="item.manager ? $t('待处理') : $t('查看')"
            :type="item.manager ? 'primary' : 'info'"
            mode="dark"
          />
          <u-tag
            v-if="option.name === '授权处理'"
            :text="item.keeper ? $t('待处理') : $t('查看')"
            :type="item.keeper ? 'primary' : 'info'"
            mode="dark"
          />
        </view>
      </uni-list-item>
    </uni-list>
  </view>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        return []
      }
    },
    option: {
      //当前页面信息，从哪里点进的
      type: Object,
      default() {
        return {}
      }
    },
    titleName: {
      //当前tab名称
      type: String,
      default() {
        return ''
      }
    }
  },
  data() {
    return {}
  },
  mounted() {
  },
  methods: {
    navigetTo(item) {
      if (
        this.option.name === '审批处理' ||
        this.option.name === '授权处理' ||
        this.option.name === '我的申请'
      ) {
        let data = {
          clickItem: item,
          option: this.option
        }
        uni.navigateTo({
          url:
            '/pages/application/applicationDetails/applicationDetails?data=' +
            encodeURIComponent(JSON.stringify(data)),
          success: (res) => {},
          fail: () => {},
          complete: () => {}
        })
      } else if (this.option.name === '审计处理') {
        if (this.titleName === '待审计') {
          let data = {
            clickItem: item,
            option: this.option
          }
          uni.navigateTo({
            url:
              '/pages/application/auditDetails/auditDetails?data=' +
              encodeURIComponent(JSON.stringify(data)),
            success: (res) => {},
            fail: () => {},
            complete: () => {}
          })
        } else {
          let data = {
            clickItem: item,
            option: this.option
          }
          uni.navigateTo({
            url:
              '/pages/application/applicationDetails/applicationDetails?data=' +
              encodeURIComponent(JSON.stringify(data)),
            success: (res) => {},
            fail: () => {},
            complete: () => {}
          })
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.good-list {
  background-color: #fff;
  width: 100%;

  .iconList {
    width: 100%;
  }
}
</style>
